/*
 * Bayes.h
 *
 *  Created on: 19-11-2011
 *      Author: cristian
 */

#ifndef BAYES_H_
#define BAYES_H_

#include <map>
#include <string>
#include <iostream>
#include <sstream>
#include <fstream>
#include "Logger.h"

/*
 * stem library
 */
#include "spanish_stem.h"



#define SPAM   0
#define NO_SPAM 1
#define PROB_SPAM  0.8
#define PROB_NO_SPAM 0.2
#define LARGO_MINIMO 2


class Bayes {
	Logger* logger;
	std::map<unsigned int, map<string, unsigned int>*>* wordsmap;
    stemming::spanish_stem<> StemSpanish;



public:
	Bayes();
	map<string, unsigned int>* getWordMap(string* word, unsigned int category);
	unsigned int  getWordCant(string* word, unsigned int category);
	void putWordInCategory(unsigned int categoria, string* word, unsigned int count);
	virtual ~Bayes();
	void loadCSVFile(string* filepath);
	void printListadoSize();
	double probabilidadSpam();
	double probabilidadNoSpam();
	double probabilidadPalabra(string* word, unsigned int categoria,unsigned int npalabras);
	unsigned int cantPalabras(unsigned int categoria);
	double probabilidadFrase(string* frase, unsigned int categoria);
	void openfileAndTest(string* filepath);
	void borrarPalabraCantMenor(unsigned int cant, unsigned int tipo);
	void borrarPalabraCantMayor(unsigned int cant, unsigned int tipo);
};

#endif /* BAYES_H_ */
